<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>

  <div id="app">
    {{time | formatdate('yyyy') | prefix }}
  </div>

  <script>

    Vue.filter('formatdate', function (value, type) {
      if (type === 'yyyy') {
        return value.split('-')[0]
      }
    })

    Vue.filter('prefix', function (val) {
      return "今天是：" + val;
    })


    var vm = new Vue({
      el: "#app",
      data: {
        time: "2020-04-03"
      }
    })
  </script>

</body>

</html>